import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lenovo
 * Date: 2025-08-22
 * Time: 18:35
 */
//https://www.nowcoder.com/practice/99eb8040d116414ea3296467ce81cbbc?tpId=230&tqId=2023819&ru=/exam/oj&qru=/ta/dynamic-programming/question-ranking&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26tab%3D%25E7%25AE%2597%25E6%25B3%2595%25E7%25AF%2587%26topicId%3D196
public class Test {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        int m=in.nextInt();
        int p=in.nextInt();
        long[][] arr=new long[n+1][m+1];
        for(int i=1;i<=n;i++){
            long sum=0;
            for(int j=1;j<=m;j++){
                sum+=in.nextInt();
                arr[i][j]=sum;
            }
        }
        for(int j=1;j<=m;j++){
            long sum=0;{
                for(int i=1;i<=n;i++){
                    sum+=arr[i][j];
                    arr[i][j]=sum;
                }
            }
        }
        while (p>0) {
            int a1 = in.nextInt();
            int a2 = in.nextInt();
            int b1 = in.nextInt();
            int b2 = in.nextInt();
            System.out.println(arr[b1][b2]+arr[a1-1][a2-1]-arr[b1][a2-1]-arr[a1-1][b2]);
            p--;
        }
    }
}
